package com.gitee.minimalismstyle.fresh.common.data.beetl.custom

import org.beetl.sql.clazz.ClassDesc
import org.beetl.sql.clazz.NameConversion
import org.beetl.sql.clazz.TableDesc
import java.util.concurrent.ConcurrentHashMap

class FreshTableDesc(name: String, remark: String) : TableDesc(name, remark) {
    //跟table相关的类，必须线程安全，是懒加载的
    private val classes: MutableMap<Class<*>, ClassDesc> = ConcurrentHashMap()

    override fun genClassDesc(c: Class<*>, nc: NameConversion): ClassDesc {
        var classDesc = classes[c]
        if (classDesc == null) {
            synchronized(classes) {
                classDesc = FreshClassDesc(c, this, nc)
                classes.put(c, classDesc!!)
            }
        }

        return classDesc!!
    }
}